package com.wantup.controller.v1;

import com.wantup.model.InMessage;
import com.wantup.model.OutMessage;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class GameInfoController {

    /**
     * 需要发布订阅
     * @param inMessage
     * @return
     */
    @MessageMapping("/v1/chat2")//路径的映射  只是 提供于 websocket 使用的
    @SendTo("/topic2/game_chat")//有很多订阅的情况下 不能通用。固定发送给指定的订阅者。
                                //SimpleMessagingTemplate
    public OutMessage getMessage(InMessage inMessage){
        System.out.println("连接建立"+inMessage);
        OutMessage outMessage = new OutMessage();
            outMessage.setContent(inMessage.getContent()).setFrom(inMessage.getFrom()) ;
        return outMessage;
    }


}
